﻿@model Tippelde.Web.Models.Home.HomeIndexModel
@{
}

<div id="carousel-example-generic" class="carousel slide">
    <!-- Indicators -->
    @if (Math.Max(Model.News.Count, Model.Events.Count) > 1)
    {
        <ol class="carousel-indicators">
            @for (int i = 0; i < (Model.News.Count + Model.Events.Count); i++)
            {
                <li data-target="#carousel-example-generic" data-slide-to="@i" class="@(i==0? "active" : "")"></li>
            }
        </ol>
    }
    <div class="carousel-inner">

        @if (Math.Max(Model.News.Count, Model.Events.Count) == 0)
        {
            <div class="jumbotron item active">
                <h1>TIPPELDE.NET</h1>
                <p class="lead">Isten hozott a Tippelde oldalán!</p>
            </div>
        }
        else
        {
            for (int i = 0; i < Math.Max(Model.News.Count, Model.Events.Count); i++)
            {
                if (i < Model.Events.Count)
                {
                    <div class="jumbotron item @(i==0? "active" : "")">
                        <h1>@Model.Events[i].HomeTeam.Name.ToUpper() - @Model.Events[i].AwayTeam.Name.ToUpper()</h1>
                        <p class="lead">@Model.Events[i].ShortName, @Model.Events[i].EventDate</p>
                        <p><a href="@Url.Action("Details", "Event", new { Id = @Model.Events[i].Id })" class="btn btn-info btn-large btn-carousel">Fogadás &raquo;</a></p>
                    </div>
                }
                if (i < Model.News.Count)
                {
                    <div class="jumbotron item @((i == 0 && Model.Events.Count==0)? "active" : "")">
                        <h1>@Model.News[i].Title.ToUpper()</h1>
                        <p class="lead">@Html.Raw(Model.News[i].ContentShort)</p>
                        <p><a href="@Url.Action("Details", "News", new { seoUrl = Model.News[i].SeoUrl })" class="btn btn-info btn-large btn-carousel">Tovább &raquo;</a></p>
                    </div>
                }
            }
        }
    </div>
    @if (Model.News.Count+Model.Events.Count > 1)
    {
        <a class="left carousel-control control-custom" href="#carousel-example-generic" data-slide="prev">
            <span class="icon-prev"></span>
        </a>
        <a class="right carousel-control control-custom" href="#carousel-example-generic" data-slide="next">
            <span class="icon-next"></span>
        </a>
    }
</div>

<div class="row">
    @if (User.Identity.IsAuthenticated)
    {
        <div class="col-md-4">
            <h2>Közelgő események</h2>
            <ul class="index-bottom-list">
                @foreach (var e in Model.Events)
                {
                    <li class="index-bottom-li event-upcoming">
                        <a href="@Url.Action("Details", "Event", new {Id =@e.Id})">
                            <span class="event-header">@e.HomeTeam.Name - @e.AwayTeam.Name </span><span class="event-type">(@e.ShortName)</span>
                            <br />
                            <span class="event-date">@e.EventDate</span>
                        </a>
                    </li>
                }
            </ul>
            <p><a href="@Url.Action("Index", "Event")" class="btn btn-default">Tovább &raquo;</a></p>
        </div>
        <div class="col-md-4">
            <h2>Legfrissebb hírek</h2>
            <ul class="index-bottom-list">
                @foreach (var n in Model.News)
                {
                    <li class="index-bottom-li newest-news"><a href="@Url.Action("Details", "News", new{seoUrl=n.SeoUrl})">@n.Title</a></li>
                }
            </ul>
            <p><a href="@Url.Action("Index", "News")" class="btn btn-default">Tovább &raquo;</a></p>
        </div>
    }
    else
    {
        <div class="col-md-6">
            <h2>Új vagy a Tippeldén?</h2>
            <p>
                Az oldal használatához jelentkezz be, vagy regisztrálj!
            </p>
            <p>
                <a class="btn btn-default" href="@Url.Action("Login","Account")">Bejelentkezés &raquo;</a>
                <a class="btn btn-primary" href="@Url.Action("Register","Account")">Regisztráció &raquo;</a>
            </p>
        </div>
    }
    <div class="col-md-@(User.Identity.IsAuthenticated ? 4 : 6)">
        <h2>Kapcsolat</h2>
        <p>Innen megtudhatod az oldallal kapcsolatos információkat, valamint elérhetőségeket</p>
        <p><a class="btn btn-default" href="@Url.Action("Contact", "Home")">Tovább &raquo;</a></p>
    </div>
</div>
@section Scripts {
    <script type="text/javascript">
        $(document).ready(function () {
            $(".carousel").carousel();
        });
    </script>
}
